package edu.cebanc.spring.biblioteca.util;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import edu.cebanc.spring.biblioteca.bean.UserBean;

public class UserValidator implements Validator {

	@Override
	public boolean supports(Class<?> clas) {
		return UserBean.class.isAssignableFrom(clas);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nombre", "name.required");
	}
}
